home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / shofkeys.arc / SHOFKEYS.A < prev    next >
Text File  |  1988-07-28  |  12KB  |  592 lines

  1.  
  2.  
  3. ;ShoFKeys -- help display line for WordPerfect (uses nth line of display)
  4. ;
  5. ; 12/5/87 by Davidson Corry
  6. ;         4610 SW Lander
  7. ;         Seattle, WA  98116
  8. ;         (206) 935-0244
  9. ;
  10. ; This program is released to the public domain by its author.
  11. ; Please feel free to use it, distribute it and (especially)
  12. ; improve it in any way you feel appropriate.
  13. ;
  14. ; Money contributions are neither required nor expected.  If you like
  15. ; the program and want to express your gratitude, do one of the following:
  16. ;
  17. ;  1) Write some useful program and upload it to your favorite BBS'es
  18. ;  2) Help support your local BBS with money, time or interest
  19. ;  3) Teach someone something about programming
  20. ;  4) Do the dishes tonight
  21. ;  5) Don't tell your lover you've heard that old joke (n) times before
  22. ;
  23. ; ...or some other public service.  Hope you find it useful.  --Davidson
  24. ;
  25.  
  26. ; shift status bits from BIOS call
  27. alt    equ    00001000b
  28. ctrl    equ    00000100b
  29. lshift    equ    00000010b
  30. rshift    equ    00000001b
  31. shifts    equ    lshift or rshift
  32. my_hotshift    equ    ctrl or lshift    ;hot key is CTRL-LEFTSHIFT-F
  33. my_hotkey    equ    33
  34.  
  35. ega    equ    1
  36. not_ega equ    0
  37.  
  38. ;Colors/attributes for display attributes
  39. blink    equ    10000000b
  40. intense equ    00001000b
  41. black    equ    0
  42. blue    equ    1
  43. green    equ    2
  44. cyan    equ    3
  45. red    equ    4
  46. magenta equ    5
  47. brown    equ    6
  48. grey    equ    7
  49. yellow    equ    intense or brown
  50. white    equ    intense or grey
  51. underline    equ    blue
  52.  
  53. ; key/function color selections for a color monitor.  Choose your own.
  54. ; Use OR rather than + to turn bits in the attribute byte on.
  55. ; Background colors occupy the high nibble: (BACKCOLOR SHL 4)
  56. ; Foreground colors occupy the low nibble:   FORECOLOR
  57.  
  58. ;KEY     EQU     INTENSE OR RED OR (CYAN SHL 4) ;"hot red" on cyan
  59. ;FNX     EQU     GREY OR (BLUE SHL 4)        ;grey on blue
  60.  
  61. ; key/function "color" selections for a monochrome monitor.
  62. ; These will work well on both color monitors (bright blue keynumber, grey words)
  63. ; and on monochrome monitors (keynumber underlined and bright, grey words)
  64.  
  65. key    equ     intense or underline    ;"hot blue" on black
  66. fnx    equ     grey            ;grey on black
  67.  
  68. in_keypress    equ    1
  69. inactivated      equ      10h
  70.  
  71. _text    segment byte public 'CODE'
  72.     assume cs:_text, ds:_text, es:_text, ss:_text
  73.     org    100h
  74.     public    begin
  75. begin:
  76.     jmp    initialize
  77.  
  78.     public    users_ss, users_sp, local_stack
  79.  
  80. users_ss    dw    0
  81. users_sp    dw    0
  82.         dw    20 dup(0)
  83. local_stack    label    word
  84.  
  85.     public    activity, adapter_type, old_keypress, last_shiftstate, video_seg
  86.  
  87. activity    db    inactivated    ;comes up "dormant" at load time
  88.  
  89. adapter_type    db    0
  90.  
  91. old_keypress    dd    0
  92.  
  93. last_shiftstate db    0
  94.  
  95. video_seg    dw    0
  96.  
  97.     public    new_keypress, not_our_hotkey, which_keyset
  98.  
  99. new_keypress:
  100.     push    ax            ;save AX register, we're going to use it
  101.     in    al,60h            ;get scancode of key just pressed
  102.     .if    <cmp     al,my_hotkey>,e    ;it's our base hotkey, see if shiftbits are right
  103.         mov    ah,2
  104.         int    16h        ;get shiftbits through BIOS
  105.         and    al,0fh        ;shiftbits only
  106.         .if    <cmp    al,my_hotshift>,e    ;it's our hotkey!! toggle ACTIVATION bit of ACTIVITY byte
  107.             in    al,61h    ;These instructions reset
  108.             mov    ah,al    ; the keyboard.  "Forgets" the hotkey
  109.             or    al,80h
  110.             out    61h,al
  111.             mov    al,ah
  112.             jmp    short $+2    ;I/O delay for fast AT's
  113.             out    61h,al
  114.             cli        ;Disable interrupts and
  115.             mov    al,20h    ;reset the int controller
  116.             out    20h,al
  117.             sti        ;Allow interrupts
  118.             xor    cs:activity,inactivated ;toggle the ACTIVATED bit in activity flag byte
  119.             pop    ax    ;restore the AX register saved at entry to hotkey test
  120.             iret        ;and return to caller
  121.         .endif
  122.     .endif
  123.     pop    ax            ;restore AX register saved above
  124.  
  125. not_our_hotkey:
  126.  
  127. ;do nothing if already in the FUNCTION KEY DISPLAY or
  128. ;  if the TSR is in the "inactivated" state
  129.     .if    <test     cs:activity,in_keypress or inactivated>,nz
  130.         jmp    cs:old_keypress
  131.     .endif
  132.  
  133. which_keyset:
  134. ;active and flying, show the function keys appropriate to the shift state
  135.     or    cs:activity,in_keypress    ;flag "showing function keys"
  136.     sti
  137.     pushf                ;simulate a INT to process the key just pressed/released
  138.     call    cs:old_keypress
  139.  
  140.     push    ax            ;save AX and SI registers, they get local values on shiftstatus
  141.     push    si
  142.     mov    ah,2
  143.     int    16h            ;get shiftstatus
  144.     .if    <test  al,alt>,nz    ;ALT is on, show ALT function keyset
  145.         mov    al,alt
  146.         mov    si,offset altfunx
  147.     .elseif  <test    al,ctrl>,nz    ;ALT not on but CTRL is, CTRL keyset
  148.         mov    al,ctrl
  149.         mov    si,offset ctrlfunx
  150.     .elseif  <test    al,shifts>,nz    ;ALT and CTRL not on but a SHIFT key is, show SHIFT keyset
  151.         mov    al,shifts
  152.         mov    si,offset shiftfunx
  153.     .else                ;ALT CTRL SHIFT all off, show "NORMAL" keyset
  154.         xor    al,al
  155.         mov    si,offset normfunx
  156.     .endif
  157.  
  158.     .if    <cmp    al,cs:last_shiftstate>,ne    ;display keyset ONLY if this is a change from last shown
  159.         call    show_new_shiftkeys
  160.     .endif
  161.  
  162.     pop    si            ;restore the registers used testing shiftstatus
  163.     pop    ax
  164.     and    cs:activity,not in_keypress    ;flag "not displaying keysets"
  165.     iret                ;and return to caller
  166.  
  167.     public    show_new_shiftkeys
  168. show_new_shiftkeys:
  169.         mov    cs:last_shiftstate,al
  170.         cli        ;disable interrupts while diddling stack
  171.         mov    cs:users_sp,sp     ;save old stack
  172.         mov    cs:users_ss,ss
  173.         mov    sp,cs    ;establish local stack instead
  174.         mov    ss,sp
  175.         mov    sp,offset local_stack
  176.         sti        ;new stack context installed, re-enable interrupts
  177.         push    ds        ;save user registers, we need 'em
  178.         push    es
  179.         push    di
  180.         push    cx
  181.         mov    ax,cs        ;get local datasegment context
  182.         mov    ds,ax
  183.         mov    cx,24        ;assume 25 rows on display, funxkeys shown on #24
  184.         .if    <cmp    adapter_type,ega>,e    ;EGA, may be using 43 rows
  185.             mov    ax,0040h
  186.             mov    es,ax
  187.             mov    cl,es:84h    ;number of last row in use
  188.         .endif
  189.         mov    ax,80*2     ;number of bytes per display row (byte char + byte attribute)
  190.         mul    cl        ;byte*byte = word, doesn't disturb DX
  191.         mov    di,ax        ;offset of last row on display
  192.         mov    ax,video_seg    ;base of video display memory
  193.         mov    es,ax
  194.         cld
  195.         mov    cx,80
  196.         rep    movsw        ;copy keyset databytes directly to video memory
  197.         pop    cx        ;restore user's registers
  198.         pop    di
  199.         pop    es
  200.         pop    ds
  201.         cli        ;disable interrupts while restoring user's stack context
  202.         mov    ss,cs:users_ss
  203.         mov    sp,cs:users_sp
  204.         sti        ;user's stack restored, enable interrupts
  205.     ret
  206.  
  207.  
  208. ; text (char+attribute) for function-key display lines
  209.  
  210.     public    normfunx, altfunx, shiftfunx, ctrlfunx
  211.  
  212. normfunx    db    '1',key
  213.     db    'c',fnx
  214.     db    'a',fnx
  215.     db    'n',fnx
  216.     db    'c',fnx
  217.     db    'e',fnx
  218.     db    'l',fnx
  219.     db    ' ',fnx
  220.     db    '2',key
  221.     db    's',fnx
  222.     db    'r',fnx
  223.     db    'c',fnx
  224.     db    'h',fnx
  225.     db    '-',fnx
  226.     db    '>',fnx
  227.     db    ' ',fnx
  228.     db    '3',key
  229.     db    ' ',fnx
  230.     db    'h',fnx
  231.     db    'e',fnx
  232.     db    'l',fnx
  233.     db    'p',fnx
  234.     db    ' ',fnx
  235.     db    ' ',fnx
  236.     db    '4',key
  237.     db    '>',fnx
  238.     db    'i',fnx
  239.     db    'n',fnx
  240.     db    'd',fnx
  241.     db    'e',fnx
  242.     db    'n',fnx
  243.     db    't',fnx
  244.     db    '5',key
  245.     db    ' ',fnx
  246.     db    'f',fnx
  247.     db    'i',fnx
  248.     db    'l',fnx
  249.     db    'e',fnx
  250.     db    's',fnx
  251.     db    ' ',fnx
  252.     db    '6',key
  253.     db    ' ',fnx
  254.     db    'b',fnx
  255.     db    'o',fnx
  256.     db    'l',fnx
  257.     db    'd',fnx
  258.     db    ' ',fnx
  259.     db    ' ',fnx
  260.     db    '7',key
  261.     db    ' ',fnx
  262.     db    'e',fnx
  263.     db    'x',fnx
  264.     db    'i',fnx
  265.     db    't',fnx
  266.     db    ' ',fnx
  267.     db    ' ',fnx
  268.     db    '8',key
  269.     db    'u',fnx
  270.     db    'n',fnx
  271.     db    'd',fnx
  272.     db    'r',fnx
  273.     db    'l',fnx
  274.     db    'i',fnx
  275.     db    'n',fnx
  276.     db    '9',key
  277.     db    'm',fnx
  278.     db    'e',fnx
  279.     db    'r',fnx
  280.     db    'g',fnx
  281.     db    'e',fnx
  282.     db    'R',fnx
  283.     db    ' ',fnx
  284.     db    '0',key
  285.     db    ' ',fnx
  286.     db    's',fnx
  287.     db    'a',fnx
  288.     db    'v',fnx
  289.     db    'e',fnx
  290.     db    ' ',fnx
  291.     db    ' ',fnx
  292.  
  293. shiftfunx     db     '1',key
  294.     db    's',fnx
  295.     db    'u',fnx
  296.     db    'p',fnx
  297.     db    '/',fnx
  298.     db    's',fnx
  299.     db    'u',fnx
  300.     db    'b',fnx
  301.     db    '2',key
  302.     db    '<',fnx
  303.     db    '-',fnx
  304.     db    's',fnx
  305.     db    'r',fnx
  306.     db    'c',fnx
  307.     db    'h',fnx
  308.     db    ' ',fnx
  309.     db    '3',key
  310.     db    's',fnx
  311.     db    'w',fnx
  312.     db    'i',fnx
  313.     db    't',fnx
  314.     db    'c',fnx
  315.     db    'h',fnx
  316.     db    ' ',fnx
  317.     db    '4',key
  318.     db    '>',fnx
  319.     db    'i',fnx
  320.     db    'n',fnx
  321.     db    'd',fnx
  322.     db    'n',fnx
  323.     db    't',fnx
  324.     db    '<',fnx
  325.     db    '5',key
  326.     db    ' ',fnx
  327.     db    'd',fnx
  328.     db    'a',fnx
  329.     db    't',fnx
  330.     db    'e',fnx
  331.     db    ' ',fnx
  332.     db    ' ',fnx
  333.     db    '6',key
  334.     db    'c',fnx
  335.     db    'e',fnx
  336.     db    'n',fnx
  337.     db    't',fnx
  338.     db    'e',fnx
  339.     db    'r',fnx
  340.     db    ' ',fnx
  341.     db    '7',key
  342.     db    ' ',fnx
  343.     db    'P',fnx
  344.     db    'r',fnx
  345.     db    'i',fnx
  346.     db    'n',fnx
  347.     db    't',fnx
  348.     db    ' ',fnx
  349.     db    '8',key
  350.     db    'L',fnx
  351.     db    'i',fnx
  352.     db    'n',fnx
  353.     db    'e',fnx
  354.     db    'F',fnx
  355.     db    'm',fnx
  356.     db    't',fnx
  357.     db    '9',key
  358.     db    'm',fnx
  359.     db    'e',fnx
  360.     db    'r',fnx
  361.     db    'g',fnx
  362.     db    'e',fnx
  363.     db    'E',fnx
  364.     db    ' ',fnx
  365.     db    '0',key
  366.     db    'r',fnx
  367.     db    'e',fnx
  368.     db    't',fnx
  369.     db    'r',fnx
  370.     db    'i',fnx
  371.     db    'e',fnx
  372.     db    'v',fnx
  373.  
  374. ctrlfunx    db    '1',key
  375.     db    ' ',fnx
  376.     db    's',fnx
  377.     db    'h',fnx
  378.     db    'e',fnx
  379.     db    'l',fnx
  380.     db    'l',fnx
  381.     db    ' ',fnx
  382.     db    '2',key
  383.     db    ' ',fnx
  384.     db    's',fnx
  385.     db    'p',fnx
  386.     db    'e',fnx
  387.     db    'l',fnx
  388.     db    'l',fnx
  389.     db    ' ',fnx
  390.     db    '3',key
  391.     db    's',fnx
  392.     db    'c',fnx
  393.     db    'r',fnx
  394.     db    'e',fnx
  395.     db    'e',fnx
  396.     db    'n',fnx
  397.     db    ' ',fnx
  398.     db    '4',key
  399.     db    ' ',fnx
  400.     db    'm',fnx
  401.     db    'o',fnx
  402.     db    'v',fnx
  403.     db    'e',fnx
  404.     db    ' ',fnx
  405.     db    ' ',fnx
  406.     db    '5',key
  407.     db    'T',fnx
  408.     db    'e',fnx
  409.     db    'x',fnx
  410.     db    't',fnx
  411.     db    ' ',fnx
  412.     db    'I',fnx
  413.     db    'O',fnx
  414.     db    '6',key
  415.     db    'T',fnx
  416.     db    'a',fnx
  417.     db    'b',fnx
  418.     db    'A',fnx
  419.     db    'l',fnx
  420.     db    'g',fnx
  421.     db    'n',fnx
  422.     db    '7',key
  423.     db    'f',fnx
  424.     db    'o',fnx
  425.     db    'o',fnx
  426.     db    't',fnx
  427.     db    'n',fnx
  428.     db    'o',fnx
  429.     db    't',fnx
  430.     db    '8',key
  431.     db    'P',fnx
  432.     db    'r',fnx
  433.     db    'n',fnx
  434.     db    't',fnx
  435.     db    'F',fnx
  436.     db    'm',fnx
  437.     db    't',fnx
  438.     db    '9',key
  439.     db    'M',fnx
  440.     db    'r',fnx
  441.     db    'g',fnx
  442.     db    'S',fnx
  443.     db    'o',fnx
  444.     db    'r',fnx
  445.     db    't',fnx
  446.     db    '0',key
  447.     db    'D',fnx
  448.     db    'e',fnx
  449.     db    'f',fnx
  450.     db    'M',fnx
  451.     db    'a',fnx
  452.     db    'c',fnx
  453.     db    'r',fnx
  454.  
  455. altfunx        db      '1',key
  456.     db    't',fnx
  457.     db    'h',fnx
  458.     db    's',fnx
  459.     db    'a',fnx
  460.     db    'r',fnx
  461.     db    'u',fnx
  462.     db    's',fnx
  463.     db    '2',key
  464.     db    'r',fnx
  465.     db    'e',fnx
  466.     db    'p',fnx
  467.     db    'l',fnx
  468.     db    'a',fnx
  469.     db    'c',fnx
  470.     db    'e',fnx
  471.     db    '3',key
  472.     db    'S',fnx
  473.     db    'h',fnx
  474.     db    'o',fnx
  475.     db    'C',fnx
  476.     db    'o',fnx
  477.     db    'd',fnx
  478.     db    'e',fnx
  479.     db    '4',key
  480.     db    ' ',fnx
  481.     db    'b',fnx
  482.     db    'l',fnx
  483.     db    'o',fnx
  484.     db    'c',fnx
  485.     db    'k',fnx
  486.     db    ' ',fnx
  487.     db    '5',key
  488.     db    ' ',fnx
  489.     db    'm',fnx
  490.     db    'a',fnx
  491.     db    'r',fnx
  492.     db    'k',fnx
  493.     db    ' ',fnx
  494.     db    ' ',fnx
  495.     db    '6',key
  496.     db    'F',fnx
  497.     db    'l',fnx
  498.     db    'u',fnx
  499.     db    's',fnx
  500.     db    'h',fnx
  501.     db    'R',fnx
  502.     db    't',fnx
  503.     db    '7',key
  504.     db    'M',fnx
  505.     db    't',fnx
  506.     db    'h',fnx
  507.     db    '+',fnx
  508.     db    'C',fnx
  509.     db    'o',fnx
  510.     db    'l',fnx
  511.     db    '8',key
  512.     db    'P',fnx
  513.     db    'a',fnx
  514.     db    'g',fnx
  515.     db    'e',fnx
  516.     db    'F',fnx
  517.     db    'm',fnx
  518.     db    't',fnx
  519.     db    '9',key
  520.     db    'M',fnx
  521.     db    'r',fnx
  522.     db    'g',fnx
  523.     db    'C',fnx
  524.     db    'o',fnx
  525.     db    'd',fnx
  526.     db    'e',fnx
  527.     db    '0',key
  528.     db    ' ',fnx
  529.     db    'M',fnx
  530.     db    'a',fnx
  531.     db    'c',fnx
  532.     db    'r',fnx
  533.     db    'o',fnx
  534.     db    ' ',fnx
  535.  
  536.  
  537.     public    initialize
  538.  
  539. initialize:
  540. ;  Deallocate the copy of the environment loaded with the program.
  541.  
  542.     mov    ax,word ptr ds:[2ch]    ;Address of environment
  543.     mov    es,ax            ;In ES register
  544.     mov    ah,49h            ;Release allocated memory
  545.     int    21h            ;Thru DOS
  546.  
  547. ;
  548. ;what kind of video adapter are we using??
  549. ;
  550.     mov    adapter_type,not_ega
  551.     mov    ax,0040h        ;BIOS data segment
  552.     mov    es,ax
  553.     mov     ah,12h            ;see if EGA is present
  554.     mov     bl,10h
  555.     int    10h
  556.     .if  <cmp bl,10h>,ne        ;EGA.  Assume it's active.
  557.         mov    ax,0b800h
  558.         mov    adapter_type,ega
  559.     .elseif    <test    word ptr es:63h,40h>,nz    ;CGA
  560.         mov    ax,0b800h
  561.     .else                ;MDA
  562.         mov    ax,0b000h
  563.     .endif
  564.     mov    video_seg,ax        ;base segment for video display memory
  565.  
  566. ;
  567. ;grab the "keypress" interrupt (9)
  568.     mov    ax,3509h
  569.     int    21h
  570.     mov    word ptr old_keypress[0],bx
  571.     mov    word ptr old_keypress[2],es
  572.     mov    dx,offset new_keypress
  573.     mov    ax,2509h
  574.     int    21h
  575.  
  576. ;
  577. ;say how to use the program
  578.     mov    dx,offset usagemsg
  579.     mov    ah,9
  580.     int    21h
  581.  
  582. ;
  583. ;exit retaining resident portion of code
  584.     mov    dx,(offset initialize - offset _text + 15)/16
  585.     mov    ax,3100h
  586.     int    21h
  587.  
  588. usagemsg    db    'CTRL-LEFTSHIFT-F toggles WordPerfect function key list on last display line$'
  589.  
  590. _text    ends
  591.     end    begin
  592.